package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.OpenPlatformEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 图片下载Request
 * @author houlong
 *
 */
public class DownloadImgRequest extends Request {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1319938839508513626L;
	
	//多媒体ID
	private String mediaId;
	//开放平台ID
	private int openPlatformId;
	
	
	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.mediaId = requestInfo.getParameter(ApiUrlParamEnum.mediaId.getParamName(), "");
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(),OpenPlatformEnum.WECHAT_HDC.getId());
		
		if (mediaId.equalsIgnoreCase("")) {
			throw new RequestIllegalException("传递错误的参数，请确认多媒体ID是否存在!");
		}
		if (openPlatformId < 1) {
			throw new RequestIllegalException("传递错误的参数，请确认平台ID是否存在!");
		}
	}

	public String getMediaId() {
		return mediaId;
	}

	public void setMediaId(String mediaId) {
		this.mediaId = mediaId;
	}

	public int getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(int openPlatformId) {
		this.openPlatformId = openPlatformId;
	}

}
